home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 1.iso / util / thedit20.zip / comm.the < prev    next >
Text File  |  1995-01-26  |  4KB  |  75 lines

  1. /*
  2. $Id: COMM.THE 2.0 1995/01/26 16:34:29 MH Release MH $
  3. */
  4. /***********************************************************************/
  5. /* Description: REXX macro to comment lines.                           */
  6. /* Syntax:      comm [target]                                          */
  7. /* Notes:       This macro will comment lines based on the file        */
  8. /*              type or file name as per below:                        */
  9. /*               .c       - /* */                                      */
  10. /*               .h       - /* */                                      */
  11. /*               .rex     - /* */                                      */
  12. /*               .rexx    - /* */                                      */
  13. /*               .pas     - (* *)                                      */
  14. /*               .asm     - ;                                          */
  15. /*               makefile - #                                          */
  16. /*               Makefile - #                                          */
  17. /*              Full XEDIT/KEDIT/THE targets are supported.            */
  18. /***********************************************************************/
  19. Trace o
  20. arg1 = Arg(1)
  21. noargs = Arg()
  22. If noargs = 0 Then arg1 = '1'               /* no args - assume 1 line */
  23. forward = 1                  /* assume direction is forward by default */
  24. 'EXTRACT /LINE/SIZE/STAY/FTYPE/FNAME/LINEND'      /* get various stuff */
  25. current_line = line.1                   /* save current line for later */
  26. reply = valid_target(arg1)                 /* validate supplied target */
  27. If reply = 'ERROR' Then
  28.    Do
  29.      'EMSG Error 0017: Invalid target' arg1
  30.      Exit
  31.    End
  32. If reply = 'NOTFOUND' Then
  33.    Do
  34.      'EMSG Error 0017: Target not found' arg1
  35.      Exit
  36.    End
  37. start_line = Word(reply,1)                        /* get starting line */
  38. nolines = Word(reply,2)                         /* get number of lines */
  39. If nolines < 0 Then Do                /* if target before current line */
  40.    forward = 0                    /* indicate direction to be backward */
  41.    nolines = nolines * -1                     /* make nolines positive */
  42. End
  43. If fname.1 = 'makefile' |  fname.1 = 'Makefile' Then 'SET LINEND OFF'
  44. ':'||start_line                                    /* go to first line */
  45. totlines = 0                             /* reset changed line counter */
  46. Do nolines                              /* for each line to target ... */
  47.    'EXTRACT /CURLINE/TOF/EOF/'       /* get current line contents, etc.*/
  48.    If tof.1 = 'ON',                    /* ignore line if on TOF or EOF */
  49.    |  eof.1 = 'ON' Then nop
  50.    Else
  51.       Do
  52.         Select               /* add comment characters to current line */
  53.           When ftype.1 = 'c' Then 'REPLACE' '/*'||curline.3||'*/'
  54.           When ftype.1 = 'h' Then 'REPLACE' '/*'||curline.3||'*/'
  55.           When ftype.1 = 'rex' Then 'REPLACE' '/*'||curline.3||'*/'
  56.           When ftype.1 = 'rexx' Then 'REPLACE' '/*'||curline.3||'*/'
  57.           When ftype.1 = 'pas' Then 'REPLACE' '(*'||curline.3||'*)'
  58.           When ftype.1 = 'asm' Then 'REPLACE' ';'||curline.3
  59.           When ftype.1 = 'sql' Then 'REPLACE' 'rem '||curline.3
  60.           When ftype.1 = 'for' Then 'REPLACE' 'C '||curline.3
  61.           When fname.1 = 'makefile' Then 'REPLACE' '#'||curline.3
  62.           When fname.1 = 'Makefile' Then 'REPLACE' '#'||curline.3
  63.           Otherwise 'REPLACE' '/*'||curline.3||'*/'
  64.         End
  65.         totlines = totlines + 1
  66.       End
  67.    If forward = 1 Then 'N'          /* if going forward, get next line */
  68.    Else 'U'                   /* if going backwards, get previous line */
  69.    If rc \= 0 Then Leave                         /* shouldn't get here */
  70. End
  71. If fname.1 = 'makefile' |  fname.1 = 'Makefile' Then 'SET LINEND' linend.1 linend.2
  72. 'EMSG' totlines 'lines commented'        /* say how many lines changed */
  73. If stay.1 = 'ON' Then ':'||current_line 
  74. Return                                               /* go back to THE */
  75.